# Contributor: alealexpro100 <alealexn@gmail.com>
# Maintainer: alealexpro100 <alealexn@gmail.com>
pkgname=rustdesk-server
_pkgver=1.1.10-3
pkgver=${_pkgver/-/.}
pkgrel=0
pkgdesc="RustDesk Server Program"
url="https://github.com/rustdesk/rustdesk-server"
# ppc64le and s390x and riscv64 blocked by ring crate
arch="all !ppc64le !s390x !riscv64"
license="GPL-3.0-or-later"
options="!check net" # RustDesk server has no tests yet
makedepends="cargo cargo-auditable"
subpackages="
	$pkgname-openrc
	"
source="
	$pkgname-$_pkgver.tar.gz::https://github.com/rustdesk/rustdesk-server/archive/refs/tags/$_pkgver.tar.gz
	hbbr.initd
	hbbs.initd
	hbbr.confd
	hbbs.confd
	cargo.lock.patch
	"
builddir="$srcdir/$pkgname-$_pkgver"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen
}

package() {
	install="$pkgname.pre-install"
	install -Dm755 "$builddir/target/release/hbbs" -t "$pkgdir/usr/bin"
	install -Dm755 "$builddir/target/release/hbbr" -t "$pkgdir/usr/bin"
	install -Dm755 "$srcdir/hbbs.initd" "$pkgdir/etc/init.d/hbbs"
	install -Dm755 "$srcdir/hbbr.initd" "$pkgdir/etc/init.d/hbbr"
	install -Dm644 "$srcdir/hbbs.confd" "$pkgdir/etc/conf.d/hbbs"
	install -Dm644 "$srcdir/hbbr.confd" "$pkgdir/etc/conf.d/hbbr"
}

sha512sums="
aada3d9ec37b85bebb57a798c9fbcb6998b334f25b04fe7dad80fe8362420cfbb6a28c75ced8f1a3a371d7667f67d1840e089cc059a78f0a161b7d63d3ffc73b  rustdesk-server-1.1.10-3.tar.gz
d94a65ec35bb3d61008c46e7c03465223c835dd277741ac2409a73df7902b461c2ac9fa853b9e20a61b56c231932ad75e29872b28a715f1e4df254edacd3f92b  hbbr.initd
87852329c8f1b011bcb9f80727259e9ad3a94332a47512f169604a114362606e51fc819544a5feaf13d22edb2dbabc22d247780acba60c8ac0228b902ed0be6b  hbbs.initd
a4b2a36449f39b0b45d789cc4a05abe489555ce2299068e4d75389e209660220fc9ab54bef7621088a33b1548336ff50183b3acc1a4204005e1d24eeb5a521da  hbbr.confd
cbe32a1d56106f8b169aca211f3a64ac8c81eb14f1e99f96692f4842714f1db142145a8246f733a4dc549f0dd046dfc48b8981d81c9ced205614900ad0a1058d  hbbs.confd
1f5c4b56ae570210424430b127662f4f410fa91dd919400a38daeb3d947c51ac599b147cc3c1c9479baea91498b0e824d3e6251581f9ba82b8fcac707824bef2  cargo.lock.patch
"
